int cmp(int* x, int* y)
{
    return *x - *y;
}

int heightChecker(int* heights, int heightsSize) {
    int* a = (int*)malloc(sizeof(int) * heightsSize);
    for (int i = 0; i < heightsSize; i++)
    {
        a[i] = heights[i];
    }
    qsort(heights, heightsSize, sizeof(int), cmp);
    int n = 0;
    for (int i = 0; i < heightsSize; i++)
    {
        if (a[i] != heights[i])
        {
            n++;
        }
    }
    return n;
}